package com.itheima.原子类;

import java.util.concurrent.atomic.AtomicInteger;

public class Demo {
    public static void main(String[] args) {
        //int get():获取值
        AtomicInteger ac1=new AtomicInteger(10);
        System.out.println(ac1.get());
        //int getAndIncrement();以原子方式将当前值加1，注意：这里返回的是自增前的值
        AtomicInteger ac2=new AtomicInteger(20);
        int andIncrement = ac2.getAndIncrement();
        System.out.println(andIncrement);
        System.out.println(ac2.get());
        //int incrementAndGet();以原子方式将当前值加1
        AtomicInteger ac3=new AtomicInteger(30);
        int i = ac3.incrementAndGet();
        System.out.println(i);
        System.out.println(ac3.get());

    }
}
